{
数据结构 解题报告：
http://git.oschina.net/et0662/sznoi-Data_Structure
}

type pnode=^node;
	node=record
		data:longint;
		before:pnode;
		next:pnode;
	end;
var
	i,n,m1,m2:longint;
	head, tail, p, temp:pnode;
	dir:boolean;
begin
	new(head);
	head^.next:=nil;
	head^.before:=nil;
	tail:=nil;

	readln(n,m1,m2);

	{ 初始化圈圈 }
	for i:=1 to n do
	begin
		new(p);
		p^.data:=i;
		p^.next:=nil;
		if(tail<>nil)then
		begin
			tail^.next:=p;
			p^.before:=tail;
		end
		else
		begin
			p^.before:=nil;
		end;
		tail:=p;
		if head^.next=nil then
		begin
			head^.next:=p;
		end;
	end;
	tail^.next:=head^.next;
	head^.next^.before:=tail;

	i:=0;
	{ dir 为方向，true正向，false反向 }
	dir:=true;
	p:=head;

	while( p^.next^.next<>p^.next)do
	begin
		if(dir)then
		begin
			inc(i);
			if(i=m1)then
			begin
				i:=1;
				dir:=not dir;
				temp:=p^.next;
				p^.next:=temp^.next;
				temp^.next^.before:=temp^.before;
				dispose(temp);
				continue;
			end;
			p:=p^.next;
		end
		else
		begin
			inc(i);
			if(i=m2)then
			begin
				i:=1;
				dir:=not dir;
				temp:=p^.before;
				p^.before:=temp^.before;
				temp^.before^.next:=temp^.next;
				dispose(temp);
				continue;
			end;
			p:=p^.before;
		end;
	end;

	writeln(p^.next^.data);
	temp:=p^.next;
	dispose(temp);
	dispose(head);
end.
